<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="150px">
      <el-form-item label="Top Money" prop="topMoney">
        <el-input v-model="form.topMoney" placeholder="Please enter top money" />
      </el-form-item>
      <el-form-item label="Auto Money" prop="autoMoney">
        <el-input v-model="form.autoMoney" placeholder="Please enter auto money" />
      </el-form-item>
      <el-form-item label="Highlight Money" prop="highlightMoney">
        <el-input v-model="form.highlightMoney" placeholder="Please enter highlight money" />
      </el-form-item>
      <el-form-item label="Normal Money" prop="normalMoney">
        <el-input v-model="form.normalMoney" placeholder="Please enter normal money" />
      </el-form-item>
      <el-form-item label="remark" prop="remark">
        <el-input v-model="form.remark" type="textarea" placeholder="Please enter remark" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">Update</el-button>
    </div>
  </div>
</template>

<script>
import { getMode, updateMode } from "@/api/system/mode";

export default {
  name: "Mode",
  data() {
    return {
      // 表单参数
      form: {
        id: 1
      },
      rules: {}
    };
  },
  created() {
    this.handleUpdate();
  },
  methods: {
    /** 修改按钮操作 */
    handleUpdate() {
      getMode(1).then(response => {
        this.form = response.data;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          // this.form.id = 1
          console.log(this.form)
          updateMode(this.form).then(response => {
            this.$modal.msgSuccess("update success");
            this.open = false;
            this.getList();
          });
        }
      });
    }
  }
};
</script>
